#!/usr/bin/env node

//类
const Koa = require('koa');

const app = new Koa();

app.use(async (ctx,next)=>{ //M-logger
  const cost = await next();
  console.log(`${ctx.method} ${ctx.path}`- `${cost}ms`);  
  
});

//p.use();

app.use((ctx,next)=>{ //M-ms
  const start = Date.now();
  next();
  const end = Date.now();
  
  return end-start;
});

app.use((ctx,next)=>{ //M-hello中间件
  ctx.body = 'hello world!';
});

app.listen(8080);

